/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ua.yandex.threadpool;

import java.util.concurrent.BlockingQueue;

/**
 *
 * @author vlad
 */
class Worker extends Thread {
    private final BlockingQueue<Runnable> workerQueue;

    public Worker(String name, BlockingQueue<Runnable> queue) {
        super(name);
        workerQueue = queue;
    }

    @Override
    public void run() {
        while (!Thread.currentThread().isInterrupted()) {
            try {
                Runnable r = workerQueue.take();
                r.run();
            } catch (InterruptedException e) {
                return;
            }
        }
    }
    
}
